#!/usr/bin/env python
# -*- coding: utf-8 -*-

import datetime
from app import db

class Foods(db.Model):

    __tablename__ = 'foods'
    # Columns
    food_id = db.Column(db.Integer, primary_key=True, autoincrement=True)

    food_name = db.Column(db.String(128))

    food_kind = db.Column(db.Integer, doc='1 pizza, 2 drink, 3 rice, 4 pasta')

    food_price = db.Column(db.Float, default=0.0)

    food_description = db.Column(db.String(512), nullable=True)

    food_pic_path = db.Column(db.String(128), nullable=True)

    create_time = db.Column(db.DateTime, default=datetime.datetime)

    edit_time = db.Column(db.DateTime, nullable=True)

    # def __repr__(self):
    #     return '<Role %r>' % self.name

class Orders(db.Model):

    __tablename__ = 'orders'
    # Columns
    order_id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    table_num = db.Column(db.Integer)
    sum = db.Column(db.Float, nullable=True)
    create_time = db.Column(db.DateTime, default=datetime.datetime)
    finish_time = db.Column(db.DateTime, nullable=True)

class OrderDeals(db.Model):
    __tablename__ = 'order_deals'
    order_id = db.Column(db.Integer)
    food_id = db.Column(db.Integer)
    count = db.Column(db.Integer)
    discount = db.Column(db.Float)
    create_time = db.Column(db.DateTime, default=datetime.datetime)
